﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using abc_ns;

namespace ece750project
{
    public struct patient_details
    {
        public int patient_pid;
        public string patient_name;
        //public string patient_lname;
    }


    public struct permision_form_param
    {
       public  int Doc_id;
       public int Patient_id;
       public int Visit_id;
    }

    public struct Appointments_form_param
    {
        public int Staff_id;
        public int Patient_id;
        public bool Direct_appointment_mode;

    }

    public struct AddNote_form_param
    {
        public string  Note;
        public bool Cancled;
        public bool Show_mode;

    }

    public struct ADDNewPatient_form_param
    {
        public int P_ID;
        public bool Cancled;
        public bool Show_mode;

    }

    public struct AddPrescription_form_param
    {
        public string title;
        public string Details;
        public DateTime  SDate;
        public bool Cancled;
        public bool Show_mode;


    }

    public enum  Person_type
    {
        Patiernt=0,
        Doctor=1,
        Staff=2,
        Finance=3
    }
    static class abc_app
    {
        public static patient_details p;
        
        public static abc_class.person_Struct current_user_personal_info;
        public static permision_form_param  permitDoctors_para;
        public static Appointments_form_param Appointments_para;

        public static AddPrescription_form_param AddPrescription_para;
        public static AddNote_form_param AddNote_para;

        public static ADDNewPatient_form_param ADDNewPatient_para;
        
        public static void msgbox(string txt,string title,Microsoft.VisualBasic.MsgBoxStyle style)
        {
            abc_class.show_MsgBox(txt, title, style);
        }

        public static bool Validate_Numaric(ref TextBox txtbox)
        {
            string S = null;
            Int16 i = default(Int16);
                
            if (Information.IsNumeric(txtbox.Text) == true)
            {
                return true;
            }
            else
            {
                for (i = 1; i <= txtbox.Text.Length; i++)
                {
                    S = txtbox.Text.Substring(0, i);
                    if (Information.IsNumeric(S) == false)
                    {
                        txtbox.SelectionStart = i - 1;
                        txtbox.SelectionLength = txtbox.Text.Length;
                        break; // TODO: might not be correct. Was : Exit For
                    }
                }
                Interaction.Beep();
                return false;
            }
        }

        public static string FormatDate(System.DateTime D, DateFormat DFormat)
        {
            string s = null;
            if (DFormat == DateFormat.GeneralDate | DFormat == DateFormat.ShortDate)
            {
                s = Strings.Format(D, "dd/MM/yyyy");
            }
            else
            {
                s = Strings.Format(D, "dd/MMMM/yyyy");
            }

            return s;
        }

        public static bool Validate_Date(object txtbox)
        {
            try
            {
                TextBox  TxtB =(TextBox) txtbox;
                if (Information.IsDate(TxtB.Text) == true)
                {
                    return true;
                }
                else
                {
                    TxtB.SelectAll();
                    Interaction.Beep();
                    return false;
                }


            }
            catch (Exception ex)
            {
                return false;
            }
        }

    }
}
